package com.mf.controller;


import com.mf.groups.GroupsUpdateInterface;
import com.mf.result.Result;
import com.mf.utils.UtilConverter;
import com.mf.entity.req.publicReq.ReqPublicIds;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;


import com.mf.entity.dto.DtoSortDetail;
import com.mf.entity.req.ReqSortDetail;
import com.mf.service.ServiceSortDetail;
import com.mf.entity.req.search.SearchReqSortDetail;

import java.util.List;

/**
 * 虚拟分拣工单明细
 *
 * @date 2025-04-21 09:19:55
 */
@RestController
@RequestMapping("sortdetail")
@Tag(name = "虚拟分拣工单明细")
public class ControllerSortDetail {
    @Resource
    private ServiceSortDetail servicesortDetail;

    @Operation(summary = "分页列表查询")
    @PostMapping("/page")
    public Result<Page<DtoSortDetail>> findPage(@RequestBody SearchReqSortDetail searchReqSortDetail) {
        return Result.success(servicesortDetail.findPageByParams(searchReqSortDetail));
    }

    @Operation(summary = "列表查询")
    @PostMapping("/list")
    public Result<List<DtoSortDetail>> list(@RequestBody SearchReqSortDetail searchReqSortDetail) {
        return Result.success(servicesortDetail.findListByParams(searchReqSortDetail));
    }

    @Operation(summary = "保存")
    @PostMapping("/save/{sortId}/{incomingId}")
    public Result<Void> save(@Validated @RequestBody ReqPublicIds<Integer> incomingDetailIds, @PathVariable Integer incomingId, @PathVariable Integer sortId) {
        servicesortDetail.saveSortDetail(sortId, incomingId, incomingDetailIds);
        return Result.success();
    }


    @Operation(summary = "删除")
    @PostMapping("/delete/{sortId}/{id}")
    public Result<Void> delete(@PathVariable Integer sortId, @PathVariable Integer id) {
        servicesortDetail.deleteById(sortId, id);
        return Result.success();
    }

}
